#ifndef __M_CHANNEL_H__
#define __M_CHANNEL_H__

#include "muduo/proto/codec.h"
#include "muduo/proto/dispatcher.h"
#include "muduo/net/TcpConnection.h"
#include "../mqcommon/mq_logger.hpp"
#include "../mqcommon/mq_helper.hpp"
#include "../mqcommon/mq_msg.pb.h"
#include "mq_consumer.hpp"
#include "mq_host.hpp"

namespace mymq
{
    using ProtobufCodecPtr = std::shared_ptr<ProtobufCodec>;
    class Channel
    {
    public:
    Channel(const std::string &id,
            const muduo::net::TcpConnectionPtr &conn,
            const ProtobufCodecPtr &codec,
            ConsumerManager::ptr &cmp,
            const VirtualHost::ptr &host);
    ~Channel();
    //交换机的声明和删除
    void declareExchange();
    void deleteExchange();

    //队列的声明和删除
    void declareQueue();
    void deleteQueue();
    //队列的绑定和解除绑定
    void queueBind();
    void queueUnBind();
    //消息的发布
    void basicPublish();
    //消息的确认
    void basicAck();
    //订阅消息队列
    void basicConsume();
    //取消订阅 
    void basicCancel();

    private: 
        std::string cid;
        Consumer::ptr _consumer;
        muduo::net::TcpConnectionPtr _conn;
        ProtobufCodecPtr _codec;
        ConsumerManager::ptr _cmp;
        VirtualHost::ptr _host;
    };
}

#endif